/*==========================================================================*
*       Copyright(c) 2009--2012 KL clear Tech
*                     ALL RIGHTS RESERVED
*
*  PRODUCT  : PRODUCT NAME
*
*  FILENAME : base_define.h
*  CREATOR  : FanXiansheng             DATE: 2012-08-27 10:57
*  VERSION  : V1000
*  PURPOSE  :
*
*
*  HISTORY  :
*
*==========================================================================*/

#ifndef BASE_DEFINE_H
#define BASE_DEFINE_H

#include "basic_data_type.h"

#define NUL_CHAR		'\0'
#define SPACE_CHAR		' '

#define UNUSED(x)		((x)=(x))

#define BMS_HI_BYTE(w)	((UINT8)((w)>>8))
#define BMS_LO_BYTE(w)	((UINT8)(w))

#define BMS_HI_WORD(dw)	((UINT16)((dw)>>16))
#define BMS_LO_WORD(dw)	((UINT16)(dw))

#define BMS_MAKE_WORD(hi, lo)	(((UINT16)(hi) << 8) | ((UINT8)(lo)))
#define BMS_MAKE_DWORD(hi, lo)	(((UINT32)(hi) << 16) | ((UINT16)(lo)))


#define BMS_SWAP_WORD(w)		\
	( ((((WORD)(w))>>8) & (WORD)0x00ff) + \
	((((WORD)(w))<<8) & (WORD)0xff00) )

#define BMS_SWAP_DWORD_BYTE(dw)		\
	( ((((DWORD)(dw))>>24) & (DWORD)0x000000ff) + \
	((((DWORD)(dw))<<24) & (DWORD)0xff000000) + \
	((((DWORD)(dw))>> 8) & (DWORD)0x0000ff00) + \
	((((DWORD)(dw))<< 8) & (DWORD)0x00ff0000) )

#define BMS_SWAP_DWORD_WORD(dw)		\
	( ((((DWORD)(dw))>>16) & (DWORD)0x0000ffff) + \
	((((DWORD)(dw))<<16) & (DWORD)0xffff0000) )


#define BMS_ITEM_OF(ArrayName)	(sizeof(ArrayName) / sizeof(ArrayName[0]))

#define BMS_SET_BIT(AllFlag, BitMask)		((AllFlag) |= (BitMask))
#define BMS_CLEAR_BIT(AllFlag, BitMask)		((AllFlag) &= (~(BitMask)))
#define BMS_BIT_IS_SET(AllFlag, BitMask)	(((AllFlag) & (BitMask)) == (BitMask))


#define BMS_MAX(a, b)		((a) >= (b) ? (a) : (b))
#define BMS_MIN(a, b)		((a) <= (b) ? (a) : (b))


#define FOR_EACH(i, k)		for (i = 0; i < k; i++)




#endif

/*-------------------------------END OF FILE-------------------------------*/
